﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace hse_2013_local_game2d
{
    public class Wave
    {
        private double sumDX;
        public double SumDX
        {
            get { return sumDX; }
        }
        private Color color;
        private int startX;
        private int endX;
        private int height;
        public int Height
        {
            get { return height; }
        }
        private double softness;
        public double Softness
        {
            get { return softness; }
        }
        private double dX;
        private int waveHeight;
        public int WaveHeight
        {
            get { return waveHeight; }
            set { waveHeight = value; }
        }
        private Plane plane;
        public Wave(int height, double dX, Plane plane,Color color)
        {
            this.sumDX = 0;
            this.startX = 0;
            this.endX = 800;
            this.height = height;
            this.softness = 0.07;
            this.dX = dX;
            this.waveHeight = 6;
            this.plane = plane;
            this.color = color;
        }
        public void Move()
        {
            if (!plane.RideMode)
            {
                startX = startX + plane.Velocity;
                endX = endX + plane.Velocity;
            }
            sumDX=sumDX+dX;
        }
        public void OnPaint(Graphics g)
        {
            for (int i = startX; i <= endX; i++)
            {
                for (int j = height-waveHeight; j <= height+waveHeight; j++)
                {
                    if (j >= height + waveHeight *Math.Sin(softness * i + sumDX))
                    {
                        g.FillRectangle(new SolidBrush(color), i, j, 1, 1);
                    }
                }
            }
            g.FillRectangle(new SolidBrush(color), startX, height + waveHeight, endX - startX, 100);
        }
    }
}
